home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FM Towns: Free Software Collection 4
/
FM Towns Free Software Collection 4 - Disc 1.iso
/
t_os
/
wstype
/
source
/
fswind_w.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-10-18
|
23KB
|
1,023 lines
/*** [fswind_w.c]
*
* ファイルセレクタウィンドウ 関連 (ワイド) (C)ささがわ
*
* For GNU C Compiler (GCC) Version 1.39
*
***/
#include <string.h>
#include <direct.h>
#include <jctype.h>
#include <dos.h>
#include "window.h"
#include "graph.h"
#include "mos.h"
#include "keyin.h"
#include "icn.h"
#include "fswind.h"
#include "beep.h"
#include "others.h"
extern int PAL_Black;
static int filehd, diroff;
static int TRIGN, ERROR;
static int curd, trhd, col;
static struct dirtree_t dt;
static struct cvars_t *cv;
static get_f gf;
static void Draw_window(void); /* カーソル */
static int Where(int, int);
static int Where_drive(int, int);
static int SUB_drive(int, int); /* カーソル */
static int Where_path(int, int);
static int SUB_path(int, int); /* カーソル */
static int Where_file(int, int);
static int SUB_file(int, int); /* カーソル */
static void SUB_scupdw(int); /* カーソル */
static int SUB_scupdw_sub(int);
static void SUB_scdr(int); /* カーソル */
static void SUB_move(int, int, struct keyin_t *); /* カーソル */
static int Where_kyb(int, int);
static void SUB_kyb(int, int); /* カーソル */
static void allcls(void); /* カーソル */
static void errord(void); /* カーソル */
static int tree_break(void);
static void Tree(int); /* カーソル */
static void SUB_trscudV(int); /* カーソル */
static int SUB_trscudV_sub(int);
static void SUB_trscudH(int); /* カーソル */
static int SUB_trscudH_sub(int);
static void trbrd(void); /* カーソル */
static void SUB_trscdrV(int); /* カーソル */
static void SUB_trscdrH(int); /* カーソル */
static int SUB_tree(int, int); /* カーソル */
static int Where_tree(int, int);
int WIND_file_w(char *path, struct cvars_t *cvars) {
int ret = 0, ret2 = 0;
struct keyin_t kt;
ERROR = 0;
TRIGN = 0;
cv = cvars;
kt.x = cv->wx + 520;
kt.y = cv->wy + 347 + 20 * cv->drw;
kt.keta = 14;
kt.foreC = PAL_Black;
kt.backC = 7;
kt.curC = 10;
kt.buf = path;
kt.bufn = 80;
Draw_window();
Keyin_init(&kt);
ICN_mos(1);
if (FSW_Draw_path(0, &diroff)) {
errord();
} else if (FSW_Draw_volid(0), FSW_Draw_diskfree(0)) {
errord();
} else {
int dm1;
char dm2;
filehd = 0;
if (FSW_Draw_file(0, filehd, &gf))
return -1;
FSW_Draw_scrollB(filehd, gf.nfiles);
MOS_rdon(1, &dm2, &dm1, &dm1, &dm1);
MOS_rdopen(1, &dm2, &dm1, &dm1, &dm1);
switch (Get_dirtree(&dt, cv->cap, tree_break)) {
case -1:
return -1;
break;
case -2:
errord();
break;
case -3:
trbrd();
break;
default:
if (!TR_Search_curd(1, &curd, cv->dirbuf, &dt)) {
errord();
} else {
trhd = 0;
col = 0;
Tree(0);
}
break;
}
}
ICN_mos(0);
while (!ret && ret2 != 1) {
char mb;
int wh, mx, my;
if ((ret2 = Keyin()) == -1)
Keyin_init(&kt);
CLOCK(0);
if (MOS_rdpos(&mb, &mx, &my), !(mb & 1))
continue;
if (wh = Where(mx, my), wh != WH_END && wh != WH_TITLE && wh != WH_OPT1 && wh != WH_OPT2 && wh != WH_DRIVE && wh != WH_KYB && wh != WH_OTHER) {
if (!ERROR) {
switch (wh) {
int sc;
case WH_PATH:
if (SUB_path(mx, my))
ret = -1;
break;
case WH_SCUP:
SUB_scupdw(1);
break;
case WH_SCDW:
SUB_scupdw(0);
break;
case WH_SCDR:
SUB_scdr(my);
break;
case WH_FILE:
if ((sc = SUB_file(mx, my)) == -2) {
ret = -1;
} else if (sc >= 0) {
strlow(1, (gf.pbuf[filehd + sc])->name);
strcpy(path, cv->dirbuf);
if (((char *)strchr(path, '\0'))[-1] != '\\')
strcat(path, "\\");
strcat(path, (char *)(gf.pbuf[filehd + sc])->name);
ret = 1;
}
break;
case WH_TRSCUPV:
SUB_trscudV(1);
break;
case WH_TRSCDWV:
SUB_trscudV(0);
break;
case WH_TRSCDRV:
SUB_trscdrV(my);
break;
case WH_TRSCUPH:
SUB_trscudH(1);
break;
case WH_TRSCDWH:
SUB_trscudH(0);
break;
case WH_TRSCDRH:
SUB_trscdrH(mx);
break;
case WH_TR:
if (SUB_tree(mx, my))
ret = -1;
break;
}
}
} else {
switch (wh) {
case WH_END:
if (FSW_end())
ret = 2;
break;
case WH_TITLE:
SUB_move(mx, my, &kt);
break;
case WH_OPT1:
if (FSW_opt1())
ret = 3;
break;
case WH_OPT2:
if (FSW_opt2(&mx, &my)) {
cv->sort = my;
if (!ERROR) {
filehd = 0;
FSW_Draw_file(2, filehd, &gf);
FSW_Draw_scrollB(filehd, gf.nfiles);
}
}
break;
case WH_DRIVE:
if (SUB_drive(mx, my))
ret = -1;
break;
case WH_KYB:
SUB_kyb(mx, my);
break;
case WH_OTHER:
do {
MOS_rdpos(&mb, &mx, &my);
} while (mb & 1);
break;
}
}
}
Gf_bufrel();
TR_bufrel();
if (ret == -1)
return -1;
else if (ret == 2)
return 0;
else if (ret == 3)
return 2;
else
return 1;
}
static void Draw_window(void) {
int a;
struct opnwin_t opw;
static const int optw[] = {
2, 2
};
a = 20 * cv->drw;
opw.title = cv->title;
opw.x1 = cv->wx;
opw.y1 = cv->wy;
opw.x2 = opw.x1 + 639;
opw.y2 = opw.y1 + 355 + a;
opw.canb = 1;
opw.nopt = 2;
opw.wopt = optw;
opw.expb = 0;
opw.shdw = 1;
opw.ord = 0;
MOS_disp(0);
drawWindow(&opw);
EGB_line(cv->wx + 5, cv->wy + 27 + a, cv->wx + 634, cv->wy + 27 + a, PAL_Black);
EGB_line(cv->wx + 249, cv->wy + 48 + a, cv->wx + 634, cv->wy + 48 + a, PAL_Black);
EGB_line(cv->wx + 249, cv->wy + 27 + a, cv->wx + 249, cv->wy + 329 + a, PAL_Black);
EGB_line(cv->wx + 5, cv->wy + 329 + a, cv->wx + 634, cv->wy + 329 + a, PAL_Black);
EGB_line(cv->wx + 517, cv->wy + 329 + a, cv->wx + 517, cv->wy + 350 + a, PAL_Black);
DrawScrollbar(0, cv->wx + 233, cv->wy + 27 + a, 287);
DrawScrollbar(1, cv->wx + 5, cv->wy + 313 + a, 229);
DrawScrollbar(0, cv->wx + 618, cv->wy + 48 + a, 282);
ICN_opt(0, cv->wx + 616, cv->wy + 8);
EGB_str2("★", cv->wx + 595, cv->wy + 23, PAL_Black);
FSW_Draw_drive();
MOS_disp(1);
}
static int Where_drive(int x, int y) {
int i = 0, xx, yy;
x -= cv->wx;
y -= cv->wy;
for (yy = 0; yy < cv->drw; yy++) {
for (xx = 0; xx < 11; xx++) {
if (i >= cv->drinfo[0])
return -1;
else if (xx * 57 + 28 < x && x < xx * 57 + 56 && yy * 20 + 29 < y && y < yy * 20 + 44)
return i;
else
i++;
}
}
return -1;
}
static int SUB_drive(int x, int y) {
int psc;
if ((psc = Where_drive(x, y)) == -1) {
char mb;
do {
int mx, my;
MOS_rdpos(&mb, &mx, &my);
} while (mb & 1);
return 0;
}
x = psc % 11;
y = psc / 11;
x = cv->wx + x * 57 + 29;
y = cv->wy + y * 20 + 30;
if (Button(x, y, x + 26, y + 13)) {
unsigned dr;
EGB_rev(1, x, y, x + 26, y + 13);
ICN_mos(1);
allcls();
_dos_setdrive(cv->drinfo[psc * 2 + 1] - 'A' + 1, &dr);
if (FSW_Draw_path(0, &diroff)) {
errord();
} else if (FSW_Draw_volid(0), FSW_Draw_diskfree(0)) {
errord();
} else {
int dm1;
char dm2;
ERROR = 0;
TRIGN = 0;
filehd = 0;
if (FSW_Draw_file(0, filehd, &gf))
return -1;
FSW_Draw_scrollB(filehd, gf.nfiles);
MOS_rdon(1, &dm2, &dm1, &dm1, &dm1);
MOS_rdopen(1, &dm2, &dm1, &dm1, &dm1);
switch(Get_dirtree(&dt, cv->cap, tree_break)) {
case -1:
return -1;
break;
case -2:
errord();
break;
case -3:
trbrd();
break;
default:
if (!TR_Search_curd(1, &curd, cv->dirbuf, &dt)) {
errord();
} else {
trhd = 0;
col = 0;
Tree(0);
}
break;
}
}
ICN_mos(0);
}
return 0;
}
static int SUB_path(int mx, int my) {
int sc, psc = -1;
int xx, yy;
char mb;
ICN_mos(2);
sc = Where_path(mx, my);
xx = cv->wx + 258;
yy = cv->wy + 30 + 20 * cv->drw;
do {
if (sc != -1) {
if (diroff == 0 && sc <= 2) {
sc = 2;
} else {
do {
sc++;
} while (sc < strlen(cv->dirbuf2) && cv->dirbuf2[sc] != '\\');
sc--;
}
}
if (sc == -1 && psc != sc)
EGB_rev(1, xx, yy, xx + (psc + 1) * 8 - 1, yy + 15);
else if (sc > psc)
EGB_rev(1, xx + (psc + 1) * 8, yy, xx + (sc + 1) * 8 - 1, yy + 15);
else if (sc < psc)
EGB_rev(1, xx + (sc + 1) * 8, yy, xx + (psc + 1) * 8 - 1, yy + 15);
psc = sc;
MOS_rdpos(&mb, &mx, &my);
sc = Where_path(mx, my);
} while (mb & 1);
ICN_mos(0);
if (psc != -1) {
if (diroff != 0)
cv->dirbuf[diroff + psc - 4] = '\0';
else
cv->dirbuf[diroff + psc + 1] = '\0';
if (strlen(cv->dirbuf) < 3)
strcpy(cv->dirbuf + 2, "\\");
ICN_mos(1);
if (chdir(cv->dirbuf)) {
errord();
} else if (FSW_Draw_path(0, &diroff)) {
errord();
} else if (!TRIGN && !TR_Search_curd(1, &curd, cv->dirbuf, &dt)) {
errord();
} else {
Tree(1);
filehd = 0;
if (FSW_Draw_file(0, filehd, &gf))
return -1;
FSW_Draw_scrollB(filehd, gf.nfiles);
}
ICN_mos(0);
}
return 0;
}
static int Where_path(int x, int y) {
int sc, ret;
x -= cv->wx;
y -= cv->wy;
if (x < 258 || 626 < x || y < 30 + 20 * cv->drw || 45 + 20 * cv->drw < y) {
ret = -1;
} else {
sc = (x - 258) / 8;
if (strlen(cv->dirbuf2) > sc)
ret = sc;
else
ret = -1;
}
return ret;
}
static void SUB_scupdw(int w) {
int xx, yy, mx, my, fllast, flpush = 1;
char mb;
if (w) {
xx = cv->wx + 619;
yy = cv->wy + 49 + 20 * cv->drw;
} else {
xx = cv->wx + 619;
yy = cv->wy + 314 + 20 * cv->drw;
}
EGB_rev(1, xx, yy, xx + 14, yy + 14);
fllast = SUB_scupdw_sub(w);
TIMER_set(20);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int whres;
whres = Where(mx, my) == (w ? WH_SCUP : WH_SCDW);
if (!whres && flpush || whres && !flpush) {
EGB_rev(1, xx, yy, xx + 14, yy + 14);
flpush = !flpush;
}
if (flpush && TIMER() && !fllast)
fllast = SUB_scupdw_sub(w);
}
if (flpush)
EGB_rev(1, xx, yy, xx + 14, yy + 14);
}
static int SUB_scupdw_sub(int w) {
if (!(w && filehd > 0 || !w && filehd + 14 < gf.nfiles))
return 1;
w ? filehd-- : filehd++;
FSW_Draw_scrollB(filehd, gf.nfiles);
EGB_color(EGB_work, EGB_COL_BACK, 7);
MOS_disp(0);
EGB_scrl(1, cv->wx + 258, cv->wy + 49 + 20 * cv->drw, cv->wx + 612, cv->wy + 328 + 20 * cv->drw, 0, w ? 20 : -20);
FSW_Draw_file_sub(w ? 0 : 13, filehd, &gf);
MOS_disp(1);
return 0;
}
static void SUB_scdr(int my) {
int mx, y;
char mb;
struct sb_t sb;
ICN_mos(3);
y = cv->wy + 65 + 20 * cv->drw;
sb.tl = gf.nfiles; sb.lpp = 14;
sb.blen = 248; sb.bml = 15;
SCRB_bar(&sb, my - y, &filehd);
FSW_Draw_scrollB(filehd, gf.nfiles);
FSW_Draw_file(1, filehd, &gf);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int a, f;
if (Where(mx, my) != WH_SCDR)
continue;
if (SCRB_bar(&sb, my - y, &a), a == filehd)
continue;
f = a < filehd;
filehd += f ? -1 : 1;
FSW_Draw_scrollB(filehd, gf.nfiles);
EGB_color(EGB_work, EGB_COL_BACK, 7);
MOS_disp(0);
EGB_scrl(1, cv->wx + 258, cv->wy + 49 + 20 * cv->drw, cv->wx + 612, cv->wy + 328 + 20 * cv->drw, 0, f ? 20 : -20);
FSW_Draw_file_sub(f ? 0 : 13, filehd, &gf);
MOS_disp(1);
}
ICN_mos(0);
}
static int SUB_file(int mx, int my) {
int sc, xx, yy, ret, psc = -1;
char mb;
xx = cv->wx + 250;
yy = cv->wy + 49 + 20 * cv->drw;
sc = Where_file(mx, my);
do {
if (psc != sc) {
if (psc != -1)
EGB_rev(1, xx, yy + psc * 20, xx + 367, yy + (psc + 1) * 20 - 1);
if (sc != -1)
EGB_rev(1, xx, yy + sc * 20, xx + 367, yy + (sc + 1) * 20 - 1);
}
psc = sc;
MOS_rdpos(&mb, &mx, &my);
sc = Where_file(mx, my);
} while (mb & 1);
if (psc == -1) {
ret = -1;
} else if ((gf.pbuf[filehd + sc])->attr & _A_SUBDIR) {
ICN_mos(1);
if (chdir((char *)(gf.pbuf[filehd + sc])->name)) {
errord();
} else if (FSW_Draw_path(0, &diroff)) {
errord();
} else if (!TRIGN && !TR_Search_curd(1, &curd, cv->dirbuf, &dt)) {
errord();
} else {
Tree(1);
filehd = 0;
if (FSW_Draw_file(0, filehd, &gf))
ret = -2;
FSW_Draw_scrollB(filehd, gf.nfiles);
}
ICN_mos(0);
ret = -1;
} else {
int i;
for (i = 0;i < 4;i++) {
for (TIMER_set(5); !TIMER(); );
EGB_rev(1, xx, yy + psc * 20, xx + 367, yy + (psc + 1) * 20 - 1);
}
ret = sc;
}
return ret;
}
static int Where_file(int mx, int my) {
int ret;
mx -= cv->wx;
my -= cv->wy;
if (mx < 250 || 617 < mx || my < 49 + 20 * cv->drw || 328 + 20 * cv->drw < my) {
ret = -1;
} else {
int sc;
sc = (my - (49 + 20 * cv->drw)) / 20;
if (filehd + sc < gf.nfiles)
ret = sc;
else
ret = -1;
}
return ret;
}
static int Where(int x, int y) {
int a, i, ret = WH_OTHER;
static const short table[19][7] = {
{5, 26, 5, 26, 0, 0, WH_END}, {26, 592, 5, 26, 0, 0, WH_TITLE},
{613, 634, 5, 26, 0, 0, WH_OPT1}, {592, 613, 5, 26, 0, 0, WH_OPT2},
{5, 634, 26, 27, 0, 1, WH_DRIVE}, {249, 634, 27, 48, 1, 1, WH_PATH},
{249, 618, 48, 329, 1, 1, WH_FILE}, {618, 634, 48, 64, 1, 1, WH_SCUP},
{618, 634, 64, 313, 1, 1, WH_SCDR}, {618, 634, 313, 329, 1, 1, WH_SCDW},
{5, 517, 329, 350, 1, 1, WH_FREE}, {517, 634, 329, 350, 1, 1, WH_KYB},
{233, 249, 27, 43, 1, 1, WH_TRSCUPV}, {233, 249, 43, 297, 1, 1, WH_TRSCDRV},
{233, 249, 297, 313, 1, 1, WH_TRSCDWV}, {5, 21, 313, 329, 1, 1, WH_TRSCUPH},
{21, 217, 313, 329, 1, 1, WH_TRSCDRH}, {217, 233, 313, 329, 1, 1, WH_TRSCDWH},
{5, 233, 27, 313, 1, 1, WH_TR}
};
x -= cv->wx;
y -= cv->wy;
a = 20 * cv->drw;
for (i = 0; i < 19; i++) {
const short *p;
p = table[i];
if (p[0] < x && x < p[1] && p[2] + (p[4] ? a : 0) < y && y < p[3] + (p[5] ? a : 0)) {
ret = p[6];
break;
}
}
return ret;
}
static void SUB_move(int x, int y, struct keyin_t *kt) {
struct RECT s, w;
w.x1 = cv->wx; w.y1 = cv->wy;
w.x2 = cv->wx + 639; w.y2 = cv->wy + 355 + 20 * cv->drw;
s.x1 = 0; s.y1 = 40; s.x2 = 639; s.y2 = 463;
if (dragWindow(x, y, &w, &s, 0, 0)) {
cv->wx = w.x1; cv->wy = w.y1;
MOS_disp(0);
EGB_cls(0);
ICN_mos(0);
MOS_disp(1);
kt->x = cv->wx + 520;
kt->y = cv->wy + 347 + 20 * cv->drw;
Draw_window();
Keyin_redisp();
if (ERROR) {
errord();
} else {
FSW_Draw_path(1, &diroff);
FSW_Draw_volid(1);
FSW_Draw_diskfree(1);
Tree(0);
FSW_Draw_file(1, filehd, &gf);
FSW_Draw_scrollB(filehd, gf.nfiles);
}
}
}
static void SUB_kyb(int mx, int my) {
int sc;
char mb;
ICN_mos(2);
sc = Where_kyb(mx, my);
do {
Keyin_cur(sc);
MOS_rdpos(&mb, &mx, &my);
sc = Where_kyb(mx, my);
} while (mb & 1);
ICN_mos(0);
}
static int Where_kyb(int x, int y) {
int ret;
x -= cv->wx;
y -= cv->wy;
if (x < 520 || 631 < x || y < 332 + 20 * cv->drw || 347 + 20 * cv->drw < y)
ret = -1;
else
ret = (x - 520) / 8;
return ret;
}
static void allcls(void) {
int a;
a = 20 * cv->drw;
MOS_disp(0);
EGB_boxf(cv->wx + 5, cv->wy + 27 + a, cv->wx + 233, cv->wy + 313 + a, PAL_Black, 7);
EGB_boxf(cv->wx + 233, cv->wy + 43 + a, cv->wx + 249, cv->wy + 297 + a, PAL_Black, 6);
EGB_boxf(cv->wx + 21, cv->wy + 313 + a, cv->wx + 217, cv->wy + 329 + a, PAL_Black, 6);
EGB_boxf(cv->wx + 249, cv->wy + 27 + a, cv->wx + 634, cv->wy + 48 + a, PAL_Black, 7);
EGB_boxf(cv->wx + 249, cv->wy + 48 + a, cv->wx + 618, cv->wy + 329 + a, PAL_Black, 7);
EGB_boxf(cv->wx + 618, cv->wy + 64 + a, cv->wx + 634, cv->wy + 313 + a, PAL_Black, 6);
EGB_boxf(cv->wx + 5, cv->wy + 329 + a, cv->wx + 517, cv->wy + 350 + a, PAL_Black, 7);
MOS_disp(1);
}
static void errord(void) {
int x, y;
char buf[5];
allcls();
FSW_getdrive(buf);
MOS_disp(0);
EGB_str2(buf, cv->wx + 258, cv->wy + 45 + 20 * cv->drw, PAL_Black);
x = cv->wx + 290;
y = cv->wy + 48 + 20 * cv->drw;
EGB_str2("ディスクの有無を確認して", x, y + 130, PAL_Black);
EGB_str2(" ドライブを選択しなおしてください", x, y + 150, PAL_Black);
MOS_disp(1);
BEP_on();
ERROR = 1;
}
static int tree_break(void) {
int ret, m2, dm;
char m1;
if (MOS_rdon(1, &m1, &m2, &dm, &dm), m1 & 2 || m2)
ret = 1;
else if (MOS_rdopen(1, &m1, &m2, &dm, &dm), m1 & 2 || m2)
ret = 1;
else
ret = 0;
return ret;
}
static void Tree(int mode) {
struct tree_t *tr;
static int pcurd;
if (TRIGN)
return;
tr = dt.tr + curd;
if (4 * col < 4 * tr->nest + strlen(tr->name) - 24) {
col = (4 * tr->nest + strlen(tr->name) - 24) / 4 + 1;
mode = 0;
} else if (tr->nest < col) {
col = tr->nest - 1;
mode = 0;
}
if (curd < trhd) {
trhd = curd - 1;
mode = 0;
} else if (curd > trhd + 13) {
trhd = curd - 12;
mode = 0;
}
if (col > dt.numc - 3)
col = dt.numc - 3;
if (col < 0)
col = 0;
if (trhd + 14 > dt.numd)
trhd = dt.numd - 14;
if (trhd < 0)
trhd = 0;
if (mode) {
int x, y;
struct tree_t *tr2;
tr2 = dt.tr + pcurd;
x = cv->wx + 7 - 32 * col;
y = cv->wy + 30 + 20 * cv->drw - 20 * trhd;
MOS_disp(0);
EGB_view(cv->wx + 7, cv->wy + 30 + 20 * cv->drw, cv->wx + 230, cv->wy + 309 + 20 * cv->drw);
EGB_rev(1, x + 32 * tr2->nest, y + 20 * pcurd, x + (4 * tr2->nest + strlen(tr2->name) + 4) * 8 - 1, y + 20 * pcurd + 19);
EGB_rev(1, x + 32 * tr->nest, y + 20 * curd, x + (4 * tr->nest + strlen(tr->name) + 4) * 8 - 1, y + 20 * curd + 19);
EGB_view(0, 0, 1023, 511);
MOS_disp(1);
} else {
FSW_Draw_tree(trhd, col, &dt, curd);
}
pcurd = curd;
}
static void SUB_trscudV(int w) {
int xx, yy, mx, my, fllast, flpush = 1;
char mb;
if (TRIGN)
return;
if (w) {
xx = cv->wx + 234;
yy = cv->wy + 28 + 20 * cv->drw;
} else {
xx = cv->wx + 234;
yy = cv->wy + 298 + 20 * cv->drw;
}
EGB_rev(1, xx, yy, xx + 14, yy + 14);
fllast = SUB_trscudV_sub(w);
TIMER_set(20);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int whres;
whres = Where(mx, my) == (w ? WH_TRSCUPV : WH_TRSCDWV);
if (!whres && flpush || whres && !flpush) {
EGB_rev(1, xx, yy, xx + 14, yy + 14);
flpush = !flpush;
}
if (flpush && TIMER() && !fllast)
fllast = SUB_trscudV_sub(w);
}
if (flpush)
EGB_rev(1, xx, yy, xx + 14, yy + 14);
}
static int SUB_trscudV_sub(int w) {
if (!(w && trhd > 0 || !w && trhd + 14 < dt.numd))
return 1;
w ? trhd-- : trhd++;
FSW_Draw_trscrlB(1, trhd, dt.numd, col, dt.numc);
EGB_color(EGB_work, EGB_COL_BACK, 7);
MOS_disp(0);
EGB_scrl(1, cv->wx + 7, cv->wy + 30 + 20 * cv->drw, cv->wx + 230, cv->wy + 309 + 20 * cv->drw, 0, w ? 20 : -20);
FSW_Draw_tree_line(trhd, col, w ? 0 : 13, &dt, curd);
MOS_disp(1);
return 0;
}
static void SUB_trscudH(int w) {
int xx, yy, mx, my, fllast, flpush = 1;
char mb;
if (TRIGN)
return;
if (w) {
xx = cv->wx + 6;
yy = cv->wy + 314 + 20 * cv->drw;
} else {
xx = cv->wx + 218;
yy = cv->wy + 314 + 20 * cv->drw;
}
EGB_rev(1, xx, yy, xx + 14, yy + 14);
fllast = SUB_trscudH_sub(w);
TIMER_set(20);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int whres;
whres = Where(mx, my) == (w ? WH_TRSCUPH : WH_TRSCDWH);
if (!whres && flpush || whres && !flpush) {
EGB_rev(1, xx, yy, xx + 14, yy + 14);
flpush = !flpush;
}
if (flpush && TIMER() && !fllast)
fllast = SUB_trscudH_sub(w);
}
if (flpush)
EGB_rev(1, xx, yy, xx + 14, yy + 14);
}
static int SUB_trscudH_sub(int w) {
int i, y;
if (!(w && col > 0 || !w && col + 7 < dt.numc + 3))
return 0;
y = cv->wy + 30 + 20 * cv->drw;
w ? col-- : col++;
FSW_Draw_trscrlB(0, trhd, dt.numd, col, dt.numc);
MOS_disp(0);
for (i = 0; i < 14; i++) {
EGB_boxf(cv->wx + 7, y + 20 * i, cv->wx + 230, y + 20 * i + 19, 7, 7);
FSW_Draw_tree_line(trhd, col, i, &dt, curd);
}
MOS_disp(1);
return 1;
}
static void trbrd(void) {
MOS_disp(0);
ICN_tree(cv->wx + 103, cv->wy + 154 + 20 * cv->drw);
MOS_disp(1);
TRIGN = 1;
}
static void SUB_trscdrV(int my) {
int y, mx;
char mb;
struct sb_t sb;
if (TRIGN) return;
ICN_mos(3);
y = cv->wy + 44 + 20 * cv->drw;
sb.tl = dt.numd; sb.lpp = 14;
sb.blen = 253; sb.bml = 15;
SCRB_bar(&sb, my - y, &trhd);
FSW_Draw_tree(trhd, col, &dt, curd);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int a, f;
if (Where(mx, my) != WH_TRSCDRV)
continue;
if (SCRB_bar(&sb, my - y, &a), a == trhd)
continue;
f = a < trhd;
trhd += f ? -1 : 1;
FSW_Draw_trscrlB(1, trhd, dt.numd, col, dt.numc);
EGB_color(EGB_work, EGB_COL_BACK, 7);
MOS_disp(0);
EGB_scrl(1, cv->wx + 7, cv->wy + 30 + 20 * cv->drw, cv->wx + 230, cv->wy + 309 + 20 * cv->drw, 0, f ? 20 : -20);
FSW_Draw_tree_line(trhd, col, f ? 0 : 13, &dt, curd);
MOS_disp(1);
}
ICN_mos(0);
}
static void SUB_trscdrH(int mx) {
int x, y, my;
char mb;
struct sb_t sb;
if (TRIGN) return;
ICN_mos(3);
x = cv->wx + 22;
y = cv->wy + 30 + 20 * cv->drw;
sb.tl = dt.numc + 3; sb.lpp = 7;
sb.blen = 195; sb.bml = 15;
SCRB_bar(&sb, mx - x, &col);
FSW_Draw_tree(trhd, col, &dt, curd);
while (MOS_rdpos(&mb, &mx, &my), mb & 1) {
int i, a, f;
if (Where(mx, my) != WH_TRSCDRH)
continue;
if (SCRB_bar(&sb, mx - x, &a), a == col)
continue;
f = a < col;
col += f ? -1 : 1;
FSW_Draw_trscrlB(0, trhd, dt.numd, col, dt.numc);
EGB_color(EGB_work, EGB_COL_BACK, 7);
MOS_disp(0);
for (i = 0; i < 14; i++) {
EGB_boxf(cv->wx + 7, y + 20 * i, cv->wx + 230, y + 20 * i + 19, 7, 7);
FSW_Draw_tree_line(trhd, col, i, &dt, curd);
}
MOS_disp(1);
}
ICN_mos(0);
}
static int SUB_tree(int mx, int my) {
int sc, xx, yy, psc = -1;
char mb;
if (TRIGN)
return 0;
xx = cv->wx + 7;
yy = cv->wy + 30 + 20 * cv->drw;
sc = Where_tree(mx, my);
do {
if (psc != sc) {
if (psc != -1)
EGB_rev(1, xx, yy + psc * 20, xx + 223, yy + psc * 20 + 19);
if (sc != -1)
EGB_rev(1, xx, yy + sc * 20, xx + 223, yy + sc * 20 + 19);
}
psc = sc;
MOS_rdpos(&mb, &mx, &my);
sc = Where_tree(mx, my);
} while (mb & 1);
if (psc != -1) {
curd = trhd + psc;
ICN_mos(1);
if (!TR_Search_curd(0, &curd, cv->dirbuf, &dt)) {
errord();
} else if (chdir(cv->dirbuf)) {
errord();
} else if (FSW_Draw_path(0, &diroff)) {
errord();
} else {
EGB_rev(1, xx, yy + psc * 20, xx + 223, yy + psc * 20 + 19);
Tree(1);
filehd = 0;
if (FSW_Draw_file(0, filehd, &gf))
return -1;
FSW_Draw_scrollB(filehd, gf.nfiles);
}
ICN_mos(0);
}
return 0;
}
static int Where_tree(int mx, int my) {
int ret;
mx -= cv->wx;
my -= cv->wy;
if (mx < 7 || 230 < mx || my < 30 + 20 * cv->drw || 309 + 20 * cv->drw < my) {
ret = -1;
} else {
int sc;
sc = (my - (30 + 20 * cv->drw)) / 20;
if (trhd + sc < dt.numd)
ret = sc;
else
ret = -1;
}
return ret;
}